package com.qing.expert.modules.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qing.expert.common.annotation.OperationLog;
import com.qing.expert.common.response.R;
import com.qing.expert.modules.admin.service.AdminFinanceService;
import com.qing.expert.modules.admin.vo.response.WithdrawVO;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/admin/withdraws")
public class AdminFinanceController {

    @Resource
    private AdminFinanceService adminFinanceService;

    /**
     * 提现审核列表
     */
    @GetMapping
    public R<Page<WithdrawVO>> getWithdrawList(
            @RequestParam(defaultValue = "0") Integer status,
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer size) {
        return R.ok(adminFinanceService.getWithdrawList(status, page, size));
    }

    /**
     * 审核提现申请
     */
    @OperationLog(action = "audit_withdraw", detail = "审核提现申请")
    @PutMapping("/{withdrawId}/audit")
    public R<Void> auditWithdraw(
            @PathVariable String withdrawId,
            @RequestParam Integer action) {
        adminFinanceService.auditWithdraw(withdrawId, action);
        return R.ok();
    }
}